package com.larkin.utils.batch;

import com.larkin.utils.config.DemoConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;

import java.util.Date;

/**
 * Created by liujin on 2019/7/8.
 *
 * @description TODO
 */
@SpringBootApplication
@ContextConfiguration(classes = {DemoConfig.class})
public class SpringBatchBootApplication {
    public static Logger logger = LoggerFactory.getLogger(SpringBatchBootApplication.class);
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringBatchBootApplication.class, args);
        logger.info("系统启动......");
        /*JobRegistry jobRegistry = context.getBean(JobRegistry.class);

        try {
            Job job = jobRegistry.getJob("messageMigrationJob");
        JobLauncher jobLauncher = context.getBean(JobLauncher.class);
        JobExecution jobExecution = jobLauncher.run(job, createJobParams());
            System.out.println(jobExecution);
        } catch (Exception e) {
            e.printStackTrace();
        }*/

    }
    private static JobParameters createJobParams() {
        //设置job运行的参数
        return new JobParametersBuilder().addDate("bizDate", new Date()).toJobParameters();
    }
}
